uses crt,dos;

var
        dir : searchrec;
        filesfound : integer;
        fname : array [0..32768] of string;
        clear : string;
        comdline : string;

function _2bin(param:integer):string;
var
         //a: integer;
          val : integer;
          srt : integer;
          bits : integer;
          ret : string;

begin

  val:=128;
  bits:=8;
  ret:='00000000';

  repeat
       begin
                //writeln(val,bits,ret);

                if (param and val) > 0 then
                begin
                     ret:=ret+'1'
                end
                else
                begin
                        ret:=ret+'0'
                end;

                val:=val div 2;
                dec(bits);
       end;
   until (bits < 1);

  _2bin:=ret;

end;




begin
  writeln ('MultiPacker v0.1 by Rafal Szyja , september 2004');
  writeln;
//  writeln ('usage: mp path outpath

  filesfound:=0;


  FindFirst('zaks\*.*',archive,Dir);
  //WriteLn('FileName'+Space(32),'FileSize':9);
  while (DosError=0) do
   begin

     inc (filesfound);

     fname [filesfound]:= _2bin(filesfound);
     comdline := 'zaks\'+dir.name+',$1000 -l$c100 -oout\'+fname[filesfound]+'.prg';
     //writeln(comdline);
     Writeln('found: '+Dir.Name+' exec: '+comdline);
     exec ('exomizer.exe ',comdline);
     if (doserror<>0) then
     begin
        writeln;
        writeln('some error concerning EXOMIZER happened');
        exit;
     end;

     exec ('prg2d64.exe ',' disk.d64 '+fname[filesfound]+' out\'+fname[filesfound]+'.prg');
     if (doserror<>0) then
     begin
        writeln;
        writeln('some error concerning prg2d64 happened');
        exit;
     end;


     FindNext(Dir);


   end;
  FindClose(Dir);



//  writeln;
 writeln(filesfound,' files found. ');

     writeln('<ENTER>');
     readln;


  end.

